from django.db import models
from vistor.models import Users
from schoolmaster.models import Student, School


# Create your models here.


class Teacher(models.Model):
    uname = models.CharField(max_length=10, null=False, verbose_name='姓名')
    uphone = models.CharField(max_length=11, null=False, verbose_name='电话')
    teacherphoto = models.ImageField(upload_to='static/photo', default='static/photo/4.jpg', verbose_name='头像')
    isDelete = models.BooleanField(default=False, verbose_name='是否删除')

    # 与用户表（1:1）
    user = models.OneToOneField(Users, null=True, verbose_name='角色')
    # 与学生表(m:m)
    students = models.ManyToManyField(Student, verbose_name='学生')
    # 与院所表（m:1)
    school = models.ForeignKey(School, related_name='teachers', verbose_name='园所')

    def __str__(self):
        return self.uname

    class Meta:
        db_table = 'teacher'
        verbose_name = '老师表'
        verbose_name_plural = verbose_name

